
<template>
  <!-- 声明式导航 -->
  <nav>
    <RouterLink to="/">Home</RouterLink>
    <RouterLink to="/about">About</RouterLink>
  </nav>
  <!-- 编程式导航 -->
  <p>
    <button @click="gotopage">跳转到购物车页</button>
    <button>跳转到我的页</button>
  </p>
  <RouterView />
</template>
<script setup>

import { RouterLink, RouterView } from 'vue-router'
import router1 from '@/router/index.js'
import { useRouter } from 'vue-router';
const router = useRouter();

console.log(router1 === router);
const gotopage = () => {
  router.push({ path: '/cart', query: { name: "小强" } })
} 
</script>


